package com.bitjsc.server.data;

import java.util.ArrayList;
import java.util.HashMap;

import org.red5.server.api.IClient;
import org.red5.server.api.IConnection;
import org.red5.server.api.service.IServiceCapableConnection;


public class Player
{
	/**
	 * 
	 */
	private static final long serialVersionUID = -3613049359364237968L;

	public HashMap<String, Card> handCard = new HashMap<String, Card>();
	
	private IClient client= null;
	private String clientID = null ;
	private Room currentRoom = null;
	private Table currentTable = null;
	private String location = Location.IN_GATE;
	private String name = null;
	private int money = 1000;
	private Boolean isBanker = false;
	private Boolean isVipPlayer = false;
	private String sex = null;
	
	private  IConnection connection = null;
	
	public Player(IConnection connection,String name)
	{
		this.connection=connection;
		this.clientID=connection.getClient().getId();
		this.name = name;
	}
	public Player()
	{
		
	}
	public void invoke(String function , Object params[])
	{
		 IServiceCapableConnection service = (IServiceCapableConnection) this.connection;
		 service.invoke(function, params);
	}

	public void setName(String name) 
	{
		this.name = name;
	}

	public String getName() 
	{
		return name;
	}

	public void setMoney(int money) 
	{
		this.money = money;
	}

	public int getMoney() 
	{
		return money;
	}
	
	public void setCurrentRoom(Room currentRoom) 
	{
		this.currentRoom = currentRoom;
	}

	public Room getCurrentRoom() 
	{
		return currentRoom;
	}

	public void setCurrentTable(Table currentTable) 
	{
		this.currentTable = currentTable;
	}
	
	public Table getCurrentTable() 
	{
		return currentTable;
	}

	public void setLocation(String location) {
		this.location = location;
	}

	public String getLocation() {
		return location;
	}

	public void setClient(IClient client) 
	{
		this.client = client;
		this.clientID=this.client.getId();
	}

	public IClient getClient() 
	{
		return client;
	}

	public void setClientID(String clientID) 
	{
		this.clientID = clientID;
	}

	public String getClientID() 
	{
		return clientID;
	}
	
	public String toString()
	{
		return this.name;		
		
	}
	
	public void setBanker(Boolean isBanker)
	{
		this.isBanker = isBanker;
	}
	
	public Boolean getBanker()
	{
		return this.isBanker;
	}
	
	public void setVipPlayer(Boolean isViPlayer)
	{
		this.isVipPlayer = isViPlayer;
	}
	public Boolean getViPlayer()
	{
		return this.isVipPlayer;
	}
	
	public ArrayList<String>  toArrayList()
	{
		
		ArrayList<String> result = new ArrayList<String>();
		result.add(this.clientID);
		result.add(this.name);
		result.add(this.location);
		result.add(String.valueOf(this.money));
		
		return  result;
		
	}
	public void setSex(String sex)
	{
		this.sex = sex;
	}
	public String getSex()
	{
		return sex;
	}
	
}
